home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / oogl / refcomm / reference.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-15  |  1.2 KB  |  57 lines

  1. /* Copyright (c) 1992 The Geometry Center; University of Minnesota
  2.    1300 South Second Street;  Minneapolis, MN  55454, USA;
  3.    
  4. This file is part of geomview/OOGL. geomview/OOGL is free software;
  5. you can redistribute it and/or modify it only under the terms given in
  6. the file COPYING, which you should have received along with this file.
  7. This and other related software may be obtained via anonymous ftp from
  8. geom.umn.edu; email: software@geom.umn.edu. */
  9. static char *copyright = "Copyright (C) 1992 The Geometry Center";
  10.  
  11. /* Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips */
  12.  
  13. /*
  14.  * Routines for operating on References -- pretty trivial, huh.
  15.  */
  16.  
  17. #include "reference.h"
  18. #include "ooglutil.h"
  19.  
  20. #ifndef NULL
  21. # define NULL 0
  22. #endif
  23.  
  24. void
  25. RefInit(register Ref *ref, long magic)
  26. {
  27.     ref->ref_count = 1;
  28.     ref->magic = magic;
  29.     ref->handle = NULL;
  30. }
  31.  
  32. RefCount(Ref *ref)
  33. {
  34.     return ref ? ref->ref_count : 0;
  35. }
  36.  
  37. Ref *
  38. RefIncr(Ref *ref)
  39. {
  40.     if(ref) ++ref->ref_count;
  41.     return ref;
  42. }
  43.  
  44. int
  45. RefDecr(Ref *ref)
  46. {
  47.     if(ref == NULL) return 0;
  48.     if(--ref->ref_count < 0) {
  49.     OOGLError(1, "RefDecr: ref %x count %d < 0!", ref, ref->ref_count);
  50.     }
  51.     return ref->ref_count;
  52. }
  53.  
  54. int
  55. RefMagic(Ref *ref) { return ref->magic; }
  56.  
  57.